package com.fable.sp.core.repository;

import com.fable.sp.core.domain.LayoutItem;
import com.slyak.spring.jpa.GenericJpaRepository;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;

import java.util.List;

/**
 * .
 *
 * @author stormning on 16/8/1.
 */
public interface LayoutItemRepository extends GenericJpaRepository<LayoutItem, Long> {
    @Override
    @CacheEvict(cacheManager = "spCacheManager", value = {"li_findByLayoutId", "li_findOne"}, allEntries = true)
    <S extends LayoutItem> S save(S entity);

    @Override
    @Cacheable(cacheManager = "spCacheManager", value = "li_findOne", key = "#p0")
    LayoutItem findOne(Long id);

    @Cacheable(cacheManager = "spCacheManager", value = "li_findByLayoutId", key = "#p0")
    List<LayoutItem> findByLayoutId(Long id);
}
